package com.lenovo.leos.filebrowser.ui;

import android.app.Activity;
import android.app.Activity.OnTitleIconClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;

import com.lenovo.leos.filebrowser.engine.util.DirDefines;
import com.lenovo.leos.filebrowser.netdisk.FileSyncServiceManager;

public class MainActivity extends Activity implements OnTitleIconClickListener {

	private static final String TAG = "MainActivity";
	private static final boolean TAG_FLAG = true;
	private static MainActivity instance = new MainActivity();
	
	public static MainActivity getInstance() {
		return instance;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);	
		bindFileSyncService();
		Intent intent = new Intent();
		if(DirDefines.mDir1.equals(getState(DirDefines.mDir1))){
			intent.putExtra("projectState", getState(DirDefines.mDir1));
		}else{
			intent.putExtra("projectState", getState(DirDefines.mDir3));
		}
		intent.setClass(MainActivity.this, TdActivity.class);
		startActivity(intent);
		
		finish();
	}
	
	private void bindFileSyncService(){
		FileSyncServiceManager manager = FileSyncServiceManager.getInstance(this);
		manager.doBindService();
	}

	public static String getState(String state) {
		//add by xieqm 110323   state
		String path = Environment.getExternalStorageDirectory().getPath();
//		String pathExtraSd = Environment.getExternalStorageDirectoryExtraSd().getPath();
//		String inState = MountServic.getVolumeState(path);
		if(TAG_FLAG){ 
			Log.d(TAG, "phone state==============================" + path);
		}
		//end
		state = DirDefines.mDir1; 
		return state;
	}

	@Override
	public void onTitleIconClick() {
		// TODO Auto-generated method stub
		finish();
	}

}
